<?php

namespace App\Http\Controllers\Applet\Sponsor;

use App\Services\Applet\Sponsor\SlaughterService;
use Exception;
use Illuminate\Http\JsonResponse;

class SlaughterController extends BaseSponsorController
{

    protected SlaughterService $slaughterService;

    /**
     * @throws Exception
     */
    public function __construct()
    {
        parent::__construct();
        $this->slaughterService = $this->loadService('Applet\Sponsor\SlaughterService');
    }

    /**
     * 申请宰杀
     * @return JsonResponse
     * @throws Exception
     */
    public function create(): JsonResponse
    {
        $rule = [
            'id' => 'required|integer|min:1',
            'userAddressId' => 'integer|min:1',
        ];

        if ($this->ruleCheck($rule)) {
            return outputJsonError();
        }

        $this->slaughterService->create($this->params);
        return outputJsonResult();
    }

}
